package com.commpany.servie.basic.product.converter;

import java.util.ArrayList;
import java.util.List;
import java.lang.reflect.Field;
import com.commpany.servie.basic.product.model.dto.product.ProductDTO;
import com.commpany.servie.basic.product.po.ProductPO;

/**
 * DTO和PO相互转换工具类
 * 
 * @author test
 * @date 2019-12-31 11:54:46
 */
public class ProductConverter {
	
	public static ProductDTO toDTO(ProductPO src) {
	if(src==null) return null;
		ProductDTO  tar = new ProductDTO();
		tar.setId(src.getId());
		tar.setProductName(src.getProductName());
		return tar;
	}

	public static ProductPO toPO(ProductDTO src) {
	if(src==null) return null;
		ProductPO  tar = new ProductPO();
		tar.setId(src.getId());
		tar.setProductName(src.getProductName());
		return tar;
	}

	public static List<ProductDTO> toDTO(List<ProductPO> srcs) {
		if (srcs == null)
			return null;
		List<ProductDTO> list = new ArrayList<ProductDTO>();
		for (ProductPO src : srcs) {
			list.add(toDTO(src));
		}
		return list;
	}

	public static List<ProductPO> toPO(List<ProductDTO> srcs) {
		if (srcs == null)
			return null;
		List<ProductPO> list = new ArrayList<ProductPO>();
		for (ProductDTO src : srcs) {
			list.add(toPO(src));
		}
		return list;
	}
}
	